import instance from '@/utils/axios.js'
// 文章频道列表
function getChannelList(){
    return instance({
        url:'/v1_0/channels',
        method:'get',
        
    })
}
// 导出接口
export{getChannelList}

function getArticleList({channel_id,timestamp}){
    return instance({
        url:'/v1_0/articles',
        method:'get',
        params:{
            with_top:1,
            channel_id,
            timestamp
        }
    })
}
export{getArticleList}
//3.获取文章详细信息
const getArticleInfo = ( id ) => {
    return instance({
      //这个接口的id直接在路径后面拼接  格式： url/id
      url: `/v1_0/articles/${id}`,
      method: 'get',
    })
  }

  //导出接口
  export { getArticleInfo }
  //4.关注用户
  const addFollowing = ( target ) => {
    return instance({
      url: `/v1_0/user/followings`,
      method: 'post',
      data:{target}
    })
  }
  
  //5.取消用户
  const removeFollowing = ( target ) => {
    return instance({
      //这个接口的id直接在路径后面拼接  格式： url/target
      url: `/v1_0/user/followings/${target}`,
      method: 'delete',
    })
  }
  //导出接口
  export { addFollowing,removeFollowing }
  //6.点赞
  const addLikings= ( target ) => {
    return instance({
      url: `/v1_0/user/followings`,
      method: 'post',
      data:{target}
    })
  }
  
  //7.取消点赞
  const removeLikings = ( target ) => {
    return instance({
      //这个接口的id直接在路径后面拼接  格式： url/target
      url: `/v1_0/user/followings/${target}`,
      method: 'delete',
    })
  }
  //导出接口
  export { addLikings,removeLikings }

  //8.不喜欢
  const addkey= ( target ) => {
    return instance({
      url: `/v1_0/user/followings`,
      method: 'post',
      data:{target}
    })
  }
  
  //9.取消不喜欢
  const removekey = ( target ) => {
    return instance({
      //这个接口的id直接在路径后面拼接  格式： url/target
      url: `/v1_0/user/followings/${target}`,
      method: 'delete',
    })
  }
  //导出接口
  export { addkey,removekey }
//   搜索推荐词列表
function getSuggestion(q){
    return instance({
        url:'/v1_0/suggestion',
        method:'get',
        params:{q}
    })
}
export{getSuggestion}

/* 9.搜索列表 */
function getSearch({page,q}){
  return instance({
    url:"/v1_0/search",
    method:'get',
    params:{
      per_page:10,
      page,q
    }
  })
}

//导出接口
export { getSearch }